package edu.ts.crowdfunding.category.web;

import edu.ts.crowdfunding.category.domain.Category;
import edu.ts.crowdfunding.category.service.CategoryService;
import edu.ts.crowdfunding.category.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName CategoryController
 * @Description TODO
 * @Author kai.jiang
 * @Date 2025/6/25 17:07
 * @Version 1.0
 */
@RestController
@RequestMapping("/category")
@Tag(name = "项目分类接口")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping("/list")
    @Operation(summary = "项目分类列表", description = "成功:1 失败:0")
    public Result list() {
        Result result = new Result();
        try {
            List<Category> list = categoryService.list();
            result.setData(list);
            result.setCode(1);
        } catch (Exception e) {
            result.setCode(0);
            throw new RuntimeException(e);
        }

        return result;
    }

}
